home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form fHeapChk
- Caption = "HeapWalker Comparison"
- ClientHeight = 3615
- ClientLeft = 3705
- ClientTop = 3405
- ClientWidth = 7425
- Height = 4020
- Left = 3645
- LinkTopic = "Form1"
- ScaleHeight = 3615
- ScaleWidth = 7425
- Top = 3060
- Width = 7545
- Begin CommandButton cmdProcess
- Caption = "&Process"
- Height = 495
- Left = 345
- TabIndex = 7
- Top = 2925
- Width = 1215
- End
- Begin CommandButton cmdClose
- Cancel = -1 'True
- Caption = "&Close"
- Height = 465
- Left = 5865
- TabIndex = 6
- Top = 2985
- Width = 1215
- End
- Begin TextBox txtOutput
- Height = 300
- Left = 3075
- TabIndex = 2
- Text = "D:\TEMP\HWDUMP.TXT"
- Top = 1485
- Width = 2460
- End
- Begin TextBox txtAfter
- Height = 315
- Left = 3075
- TabIndex = 1
- Text = "D:\MSVC\BIN\HWG01.TXT"
- Top = 795
- Width = 2475
- End
- Begin TextBox txtBefore
- Height = 315
- Left = 3060
- TabIndex = 0
- Text = "D:\MSVC\BIN\HWG00.TXT"
- Top = 120
- Width = 2475
- End
- Begin Label lblMisc
- Alignment = 1 'Right Justify
- Height = 270
- Index = 4
- Left = 4065
- TabIndex = 9
- Top = 2115
- Width = 855
- End
- Begin Label lblMisc
- Caption = "Processing Line:"
- Height = 270
- Index = 3
- Left = 2355
- TabIndex = 8
- Top = 2130
- Width = 1590
- End
- Begin Label lblMisc
- Caption = "Output File:"
- Height = 270
- Index = 2
- Left = 1680
- TabIndex = 5
- Top = 1530
- Width = 1215
- End
- Begin Label lblMisc
- Caption = "After File:"
- Height = 270
- Index = 1
- Left = 1620
- TabIndex = 4
- Top = 825
- Width = 1215
- End
- Begin Label lblMisc
- Caption = "Before File:"
- Height = 270
- Index = 0
- Left = 1620
- TabIndex = 3
- Top = 150
- Width = 1215
- End
- 'HeapCheck - by TBO/MicroHelp, Inc.
- 'this program is nothing fancy - it was written originally for in-house use
- 'so our Muscle product is used for expediency. You can replace the two Muscle
- 'routines used with VB code if you want to modify this program and do not
- 'have Muscle. If you don't have Muscle, you will NOT be able to run this
- 'in the VB IDE
- 'Suggestion - before doing a "Before" dump, make Windows as clean as possible
- 'by unloading everything but your shell. Do the "Before" snapshot, load your
- 'application, then do the "After" snapshot.
- 'If you do a snapshot after the target app has been unloaded and compare it against
- 'the original before, you will normally find several items in the dump file, this
- 'is normal and is caused by Windows moving segments. You will need to look at this
- 'output closely to see if the application is "dirty" and left some trash behind.
- 'The file names have been hard-coded for simplicity - you can easily change
- 'them to your defaults
- DefInt A-Z 'Always a good idea
- Option Explicit 'you should get used to this as well
- Declare Function MhFileExists% Lib "Muscle.vbx" (ByVal FileSpec$)
- Declare Function MhFileSearch& Lib "Muscle.vbx" (ByVal CaseSens%, Start&, Search$, ByVal File$)
- Dim isCancel 'bool - cancel flag
- Sub cmdClose_Click ()
- 'not sophisticated, but it works
- If cmdClose.Caption = "&Cancel" Then
- isCancel = True
- Else
- Unload Me
- End If
- End Sub
- Sub cmdProcess_Click ()
- 'if this was something other than a simple program, all code would be in a module
- 'vs this form
- ProcessFiles
- End Sub
- Sub ProcessFiles ()
- 'compares file in txtAfter to txtBefore and puts all lines not found in txtOutput
- 'since this routine uses MhFileSearch, it will also log any lines that have changed
- 'vs only those that are only new / additional
- 'minimal error checking provided
- Dim sAfter As String
- Dim sBefore As String
- Dim sOutput As String
- Dim sInput As String
- Dim lStart As Long
- Dim lLineCount As Long
- 'since we used Defint A-Z - no need for data type, just Dim for option explicit
- Dim iAfterHandle
- Dim iOutputHandle
- Dim iZero
- Dim iCaseSens
- isCancel = False
- If Not (MhFileExists(txtBefore.Text)) Or Not (MhFileExists(txtAfter.Text)) Then
- MsgBox "Incorrect file name"
- Else
- 'Open the after file and read in one line at a time, comparing it to the before file
- On Error GoTo ErrProcessFiles
- 'accessing control properties is slower than accessing strings, so store any properties used more than once
- sBefore = txtBefore.Text
- sAfter = txtAfter.Text
- sOutput = txtOutput.Text
- iAfterHandle = FreeFile
- Open sAfter For Input As iAfterHandle
- iOutputHandle = FreeFile
- Open sOutput For Output As iOutputHandle
- cmdClose.Caption = "&Cancel"
- cmdProcess.Enabled = False
- Do Until EOF(iAfterHandle)
- Line Input #iAfterHandle, sInput 'read in a line from the after file
- lLineCount = lLineCount + 1
- lblMisc(4).Caption = Str$(lLineCount)
- DoEvents
- If isCancel Then Exit Do
- If MhFileSearch(iCaseSens, lStart, sInput, sBefore) <= iZero Then
- 'if less than zero, it's not in the file
- Print #iOutputHandle, sInput 'save it in our output file
- End If
- Loop
- cmdClose.Caption = "&Close"
- cmdProcess.Enabled = True
- Close iAfterHandle
- Close iOutputHandle
- If FileLen(sOutput) = iZero Then
- 'they're identical - kill the zero length file
- Kill sOutput
- MsgBox "No Differences in the files!?"
- Else
- MsgBox "Done!"
- End If
- End If
- Exit Sub
- ErrProcessFiles:
- cmdClose.Caption = "&Close"
- cmdProcess.Enabled = True
- MsgBox "File I/O Error"
- Exit Sub
- End Sub
-